package com.otaku.admin.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.otaku.admin.dao.entity.Role;
import com.otaku.admin.dao.entity.RolePermission;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface RolePermissionMapper extends BaseMapper<RolePermission> {

    @Select("select * from sys_role_permission " +
            "where role_id = #{rolePerm.roleId} and perm_id = #{rolePerm.permId}")
    List<RolePermission> findByRoleAndPerm(@Param("rolePerm")RolePermission rolePermission);

    @Delete("delete from sys_role_permission " +
            "where role_id = #{rolePerm.roleId} and perm_id = #{rolePerm.permId}")
    void deleteByRoleAndPerm(@Param("rolePerm")RolePermission rolePermission);
}
